<?php
//require_once 'classloader.inc.php';
/* Session starten oder wieder aufnehmen */
session_start();

/* Datenbank einbinden */
include "db.inc.php";

/* Aufruf vom Formular */
if (isset($_POST['login']))
{
	$log_name = $_POST['log_name'];
	$log_password = $_POST['log_password'];

	/* Benutzer in Datenbank abfragen */
	$login = mysql_query("
			SELECT log_name, log_password
			FROM login
			WHERE log_name = '$log_name'");

	if(mysql_fetch_row($login) > 0)
	{
		$db_name = mysql_result($login, 0, 'log_name');
		$db_password = mysql_result($login, 0, 'log_password');
	}
	else
	{
		$db_name = '';
		$db_password = '0';
	}
	/* Falls Name und Passwort korrekt */
	if ($log_name == $db_name && $log_password == $db_password)
	{
		$_SESSION['log_name'] = $log_name;
		$_SESSION['log_password'] = $log_password;
	}
}
?>
<!DOCTYPE html>
<!--
****************************
*    Design and            *
*    Programming by        *
*    j.herzig              *
****************************
//-->




<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>.: Willkommen beim Adrian Herzig :.</title>
<meta charset="utf-8">
<meta name="author" content="J.Herzig" />
<meta name="description" content="Spargeln aus Wynau Herzig Adrian" />
<meta name="keywords"
	content="Spargeln, Wynau, Gem&uuml;se Wynau, Spargeln Wynau, Spargeln Adrian Herzig, Herzig Adrian Spargeln" />
<meta name="robots" content="index" />
<meta name="robots" content="nofollow" />
<meta name="googlebot" content="index, follow" />
<meta name="google-site-verification"
	content="RajSng1wIAWCupVKaNLOYrNcwA0rjd7P-lJ3GcYgGsc" />
<meta name="revisit-after" content="30 days" />
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<script type="text/javascript" src="js/sha1.js"></script>
<script type="text/javascript" src="js/treeMenu.js"></script>
<script type="text/javascript" src="js/menuscript01.js"></script>
<script type="text/javascript">
	/* <![CDATA[ */
		/* Anfang Passwortverschluesselung */
		function checkform()
		{
			var returnvalue = true;
			if(document.login.log_name.value == '')
			{
				alert("Bitte geben Sie einen Benutzernamen ein");
				document.login.log_name.focus();
				returnvalue = false;
			}
			if(document.login.log_password.value == '')
			{
				alert("Bitte geben Sie ein Passwort ein");
				document.login.log_password.focus();
				returnvalue = false;
			}
			if(true == returnvalue)
			{
				if(40 != document.login.log_password.value.length)
				{
				document.login.log_password.value = hex_sha1(document.login.log_password.value);
				}
			}
			return returnvalue;
		}
	/* ]]> */
	</script>
<!--[if lt IE 9] -->
<script type="text/javascript">
		  document.createElement("nav");
		  document.createElement("header");
		  document.createElement("footer");
		  document.createElement("section");
		  document.createElement("aside");
		  document.createElement("article");
		</script>
<!--[endif] -->


</head>
<body>

	<!-- BEGIN: page_container -->
	<section id="page_container">
		<!-- BEGIN: HEADER -->
		<header id="header">
			<?php
			require("mod/template/header.inc.php");
			?>
		</header>
		<!-- END: HEADER -->

		<section id="page_container2" class="clearfix">
			<!-- BEGIN: PAGE SECTION -->
			<section id="page_section">
				<!-- BEGIN: ARTICLE -->
				<article id="page_article">
					<?php
					/* Kontrolle ob ID vorhanden oder nicht */
					if(isset($_GET['id']))
					{
						/* ID abfangen */
						if($_GET['id'] == 'nav_edit')
						{
							if (isset($_SESSION['log_name']))
							{
								require("mod/edit/nav_edit.inc.php");
							}
							else
							{
								require("mod/login/log.inc.php");
							}
						}
						if($_GET['id'] == 'content_edit')
						{
							if (isset($_SESSION['log_name']))
							{
								require("mod/edit/content_edit.inc.php");
							}
							else
							{
								require("mod/login/log.inc.php");
							}
						}
						if($_GET['id'] > 0)
						{
							require("mod/inhalt/content.inc.php");
						}
					}
					else
					{
						require("mod/inhalt/content.inc.php");
					}
					?>
				</article>
				<!-- END: ARTICLE -->

				<!-- BEGIN: LEFT COLUMN -->
				<section id="column_left">
					<!-- BEGIN: MAIN MENU -->
					<nav class="menu">
						<?php
						//TODO Klass Loder
						require("navigation.inc.php");
						if(isset($_GET['id'])){
							$nav = new Navigation($_GET['id']);
						}
						else {
							$nav = new Navigation(0);
						}
						echo $nav->getNavigation();
						?>
					</nav>
					<!-- END: MAIN MENU -->
					<article id="column_left_article">
						<?php 
						$filename = "mod/template/hauptsponsor.inc.php";
						if(file_exists($filename)){
								require("mod/template/hauptsponsor.inc.php");
							}
							?>
					</article>
				</section>
				<!-- END: LEFT COLUMN -->
			</section>
			<!-- END: PAGE SECTION -->
		</section>

		<!-- BEGIN: FOOTER -->
		<footer id="page_footer">
			<section id="left">Design by j.herzig</section>
		</footer>
		<!-- END: FOOTER -->

	</section>
	<!-- END: page_container -->
</body>
</html>
